package cn.zlp.hrm.controller;

import cn.zlp.hrm.doc.CourseDoc;
import cn.zlp.hrm.query.CourseDocQuery;
import cn.zlp.hrm.repository.CourseDocRepository;
import cn.zlp.hrm.service.ICourseDocService;
import cn.zlp.hrm.util.AjaxResult;
import cn.zlp.hrm.util.PageList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 调用接口编写
 * @program: hrm-parent
 * @author: Mr.Zhang
 * @create: 2022-01-10 00:06
 **/
@RestController
@RequestMapping("/courseDoc")
public class CourseDocController {

    @Autowired
    private ICourseDocService courseDocService;

    /**
     * 批量添加
     * 注意不能使用batchmapping 应为es不支持
     * @param docs
     * @return
     */
    @PostMapping("/add")
    @PreAuthorize("hasAuthority('search:batchAdd')")
    public AjaxResult batchAdd(@RequestBody List<CourseDoc> docs){
        return courseDocService.batchAdd(docs);
    }

    /**
     * 批量删除
     * @param ids
     * @return
     */
    @PostMapping("/del")
    @PreAuthorize("hasAuthority('search:batchDel')")
    public AjaxResult batchDel(@RequestBody List<Long> ids){
        return courseDocService.batchDel(ids);
    }

    @PostMapping("/queryCourses")
    public PageList<CourseDoc> queryPageData(@RequestBody CourseDocQuery query){
        return courseDocService.queryPageData(query);
    }

}
